//
//  ZZBaseViewController.swift
//  SinaWeibo
//
//  Created by QUAN on 15/11/9.
//  Copyright © 2015年 QUAN. All rights reserved.
//

import UIKit

class ZZBaseViewController: UITableViewController,ZZVisitorLoginViewDeleget {

    
    var userLogin = ZZUserAccount.loadAccount() != nil
   
    var visitorLoginView : ZZVisitorLoginView?
    //纯手写代码专用
    override func loadView() {
        userLogin ? super.loadView() : loadVisiorView()
    }
    
    private func loadVisiorView() {
        visitorLoginView = ZZVisitorLoginView()
        
        //设置代理
        visitorLoginView?.visitorDelegate = self
        
        //添加按钮
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorWillLogin")
        
        //重写View
        view = visitorLoginView
    }
    
    func visitorWillLogin() {

        print(__FUNCTION__)
        
        //跳转控制器
        let oauth = ZZOAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func visitorWillRegister() {
        print(__FUNCTION__)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
}




